home *** CD-ROM | disk | FTP | other *** search
/ PC Advisor 2011 May / PC Advisor 190 E.iso / pc / ESSENTIALS / VLC Media Player 1.1 / vlc-1.1.5-win32.exe / lua / sd / freebox.lua < prev    next >
Encoding:
Text File  |  2010-11-13  |  1.8 KB  |  56 lines

  1. --[[
  2.  $Id$
  3.  
  4.  Copyright ┬⌐ 2010 VideoLAN and AUTHORS
  5.  
  6.  Authors: Fabio Ritrovato <sephiroth87 at videolan dot org>
  7.  
  8.  This program is free software; you can redistribute it and/or modify
  9.  it under the terms of the GNU General Public License as published by
  10.  the Free Software Foundation; either version 2 of the License, or
  11.  (at your option) any later version.
  12.  
  13.  This program is distributed in the hope that it will be useful,
  14.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  GNU General Public License for more details.
  17.  
  18.  You should have received a copy of the GNU General Public License
  19.  along with this program; if not, write to the Free Software
  20.  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  21. --]]
  22.  
  23. function descriptor()
  24.     return { title="Freebox TV" }
  25. end
  26.  
  27. function main()
  28.     local fd, msg = vlc.stream( "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u" )
  29.     if not fd then
  30.         vlc.msg.warn(msg)
  31.         return nil
  32.     end
  33.     local line=  fd:readline()
  34.     if line ~= "#EXTM3U" then
  35.         return nil
  36.     end
  37.     line = fd:readline()
  38.     local duration, artist, name
  39.     local options={"deinterlace=1"}
  40.     while line ~= nil do
  41.         if( string.find( line, "#EXTINF" ) ) then
  42.             _, _, duration, artist, name = string.find( line, ":(%w+),(%w+)%s*-%s*(.+)" )
  43.         elseif( string.find( line, "#EXTVLCOPT" ) ) then
  44.             _, _, option = string.find( line, ":(.+)" )
  45.             table.insert( options, option )
  46.         else
  47.             vlc.sd.add_item( {path=line,duration=duration,artist=artist,title=name,options=options} )
  48.             duration = nil
  49.             artist = nil
  50.             name = nil
  51.             options={"deinterlace=1"}
  52.         end
  53.         line = fd:readline()
  54.     end
  55. end
  56.